import requests
from bs4 import BeautifulSoup
f=open('log.txt','a')

ua = {
    'User-Agent':
    'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36'
}

r = requests.get('https://www.huya.com/g/lol', headers=ua)
r.encoding='utf8'
# print(r.text)
html=BeautifulSoup(r.text,'html.parser')
news_list=html.select('li.game-live-item')
result=[]
for news in news_list:
   news_info={}
   url_element=news.select('a.title')
   news_info['标题']=url_element[0].text.strip()

   result.append(news_info)
print(result)
